﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
	public class CellDefinition
	{

		private List<Attribut> attribute;

		public List<Attribut> Attribute
		{
			get { return attribute; }
			set { attribute = value; }
		}

		private string zellTyp;
		public string ZellTyp
		{
			get { return zellTyp; }
			set { zellTyp = value; }
		}

		public CellDefinition(List<Attribut> attribut, string zellTyp)
		{
			if (attribut == null)
				this.Attribute = new List<Attribut>();
			else
				this.Attribute = attribut;
			this.zellTyp = zellTyp;
		}

		public CellDefinition(string zellTyp)
		{
			this.Attribute = new List<Attribut>();
			this.zellTyp = zellTyp;
		}

		public void addAttribut(Attribut attr)
		{
			attribute.Add(attr);
		}

		public Attribut getAttribut(string name)
		{
			foreach (Attribut tmpAttr in attribute)
			{
				if (tmpAttr.Name.Equals(name))
					return tmpAttr;
			}

			return null;
		}

		public override string ToString()
		{
			//string returnstring = "Zelle: Zelltyp=" + zellTyp + "[";
			//foreach (Attribut tmpAttribut in attribute)
			//{
			//	returnstring += "[" + tmpAttribut + "], ";
			//}

			//int lastInd = returnstring.LastIndexOf(",");
			//returnstring = returnstring.Substring(0, lastInd) + "]";
			return this.zellTyp;
		}
	}
}
